package com.huike.web.controller.report;


import com.huike.common.core.domain.AjaxResult;
import com.huike.report.result.ReportIndexStatisticsData;
import com.huike.report.service.IndexService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.List;

/**
 * @Description 首页报表相关接口
 * @Date 2023-10-10
 */
@RestController
@RequestMapping("/index")
@Slf4j
@Api(tags = "首页报表相关接口")
@RequiredArgsConstructor
public class IndexController {

    private final IndexService indexService;




    /**
     * 基础数据统计请求
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getBaseInfo")
    @ApiOperation("基础数据统计接口")
    public AjaxResult getBaseInfo(
            @RequestParam("beginCreateTime") String beginCreateTime,
            @RequestParam("endCreateTime") String endCreateTime
    ){
        log.info("开始执行基础数据统计接口：{},{}",beginCreateTime,endCreateTime);
        return AjaxResult.success(indexService.getBaseInfo(beginCreateTime, endCreateTime));
    }

    /**
     * 获取今日数据简报请求
     * @return
     */
    @GetMapping("/getTodayInfo")
    @ApiOperation("获取今日数据简报接口")
    public AjaxResult getTodayInfo() {
        log.info("开始执行获取今日数据简报接口。。。。。");
        return AjaxResult.success(indexService.getTodayInfo());
    }

    /**
     * 待办数据
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getTodoInfo")
    @ApiOperation("获取代办数据接口")
    public AjaxResult getTodoInfo(
            @RequestParam("beginCreateTime") String beginCreateTime,
            @RequestParam("endCreateTime") String endCreateTime
    ) {
        log.info("开始执行获取代办数据接口：{}，{}", beginCreateTime,endCreateTime);
        return AjaxResult.success(indexService.getTodoInfo(beginCreateTime,endCreateTime));
    }

    /**
     * 商机龙虎榜
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/businessChangeStatistics")
    public AjaxResult businessChangeStatistics(@RequestParam("beginCreateTime") String beginCreateTime,
                                               @RequestParam("endCreateTime") String endCreateTime){
        log.info("开始执行商机龙虎榜。。。。。{}，{}",beginCreateTime,endCreateTime);
        List<ReportIndexStatisticsData> businessChangeStatistics= indexService.businessChangeStatistics(beginCreateTime,endCreateTime);
        return AjaxResult.success(businessChangeStatistics) ;
    }

/*

    /**
     * 线索龙虎榜
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */

    /*

    @GetMapping("/salesStatistic")
    public AjaxResult salesStatistic(@RequestParam("beginCreateTime") String beginCreateTime,
                                     @RequestParam("endCreateTime") String endCreateTime){
        List<ReportIndexStatisticsData> salesStatistic= indexService.salesStatistic(beginCreateTime,endCreateTime);
        return AjaxResult.success(salesStatistic) ;
    }
*/




    /**
     * 线索转化龙虎榜
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @ApiOperation("线索转化龙虎榜接口")
    @GetMapping("/salesStatistic")
    public AjaxResult salesStatistic(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate beginCreateTime,
                                    @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endCreateTime){

        log.info("开始执行线索转化龙虎榜接口：{}",beginCreateTime,endCreateTime);

        List<ReportIndexStatisticsData> reportIndexStatisticsDataList = indexService.salesStatistic(beginCreateTime,endCreateTime);

        return AjaxResult.success(reportIndexStatisticsDataList) ;
    }









}
